<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            width: 300px;
            height: 300px;
            background-color: pink;
            margin: auto;
            position: relative;
            text-align: center;
            display: none;
        }
        .box span {
            position: absolute;
            right: 5px;
            top: 5px;
        }
    </style>
    
</head>
<body>
    <div class="box">我是广告<span>×</span></div>
<script>
    var odiv = document.querySelector('div')
    var spans = odiv.querySelector('span')
    
    function fn(){
        // 调用函数后三秒 出现
        setTimeout(function(){
        odiv.style.display='block'

    },3000)
    }
    spans.onclick=function(){
        // 点击关闭后触发函数  永远关不掉
        odiv.style.display='none'
        fn()        
    }
    fn()

    
</script>
</body>
</html>